//package com.wechat.conf;
//
//import com.zaxxer.hikari.HikariDataSource;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//import org.springframework.transaction.annotation.EnableTransactionManagement;
//
//import javax.sql.DataSource;
//
//
//@Configuration
//@MapperScan("com.wechat.mapper")
//@EnableTransactionManagement
//public class MyBatisConfiguration {
//    @Value("${spring.datasource.driver-class-name}")
//    private String driverClassName;
//    @Value("${spring.datasource.url}")
//    private String url;
//    @Value("${spring.datasource.username}")
//    private String username;
//    @Value("${spring.datasource.password}")
//    private String password;
//
//    @Bean(destroyMethod = "close")
//    @Primary
//    public DataSource primaryDataSource() {
//        HikariDataSource hikariDataSource = new HikariDataSource();
//        hikariDataSource.setPoolName("springHikariCP");
//        hikariDataSource.setDriverClassName(driverClassName);
//        hikariDataSource.setJdbcUrl(url);
//        hikariDataSource.setUsername(username);
//        hikariDataSource.setPassword(password);
//        return hikariDataSource;
//    }
//
//    @Bean
//    public DataSourceTransactionManager makeDataSourceTransactionManager(DataSource dataSource) {
//        DataSourceTransactionManager manager = new DataSourceTransactionManager();
//        manager.setDataSource(dataSource);
//        return manager;
//    }
//
//    @Bean
//    public SqlSessionFactory makeSqlSessionFactoryBean(DataSource dataSource) throws Exception {
//        SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
//        sessionFactory.setDataSource(dataSource);
//        sessionFactory.setTypeAliasesPackage("com.wechat.domain");
//        return sessionFactory.getObject();
//    }
//
//}
